package com.lindroy.androidplayer.viewmodels

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import androidx.paging.PagingData
import androidx.paging.cachedIn
import com.lindroy.androidplayer.logic.network.repository.Repository
import com.lindroy.androidplayer.utils.mapArticleData
import com.lindroy.androidplayer.utils.mapSingle
import kotlinx.coroutines.flow.Flow

/**
 * @author Lin
 * @date 2022/2/25
 * @function
 */
class MyShareViewModel : PageViewModel() {

    private val itemClickAction = MutableLiveData<ArticleItemViewModel>()

    val itemClickLiveData = itemClickAction.mapSingle { it }

    val shareArticles: Flow<PagingData<ArticleItemViewModel>>
        get() = Repository.myShareArticles.mapArticleData(itemClickAction)
            .cachedIn(viewModelScope)

}